import {useCallback} from 'react';
import {useSelector, useDispatch} from 'react-redux';
import tabsApi from '../api/tabs';
import Creators from '../store/actions';


export const useTabs = () => {
    const minetabs = useSelector (state => state.minetabs);
    // console.log(minetabs);
    const dispatch = useDispatch ();

    const getTabs = useCallback (
        async navs_id=> {
        const data=  await tabsApi.tabs(navs_id);
        dispatch (Creators.getTabs({data}));
      },
      [dispatch]
    );
  
    // const changeTab=useCallback (
    //   async _id => {
    //     console.log("in");
    //     console.log(_id);
    //     const newData = await tabsApi.changes(_id);
    //     // console.log(newData);
    //     dispatch (Creators.changesTabs(newData));
    //   },
    //   [dispatch]
    // );changeTab
    return [minetabs, {getTabs}];
  };